﻿namespace NoIdeaIoc;
/// <summary>
/// 创建Ioc容器的接口
/// </summary>
public interface IContainerBuilder : IServiceCollection
{
    /// <summary>
    /// 添加HttpClient服务
    /// </summary>
    /// <returns></returns>
    IContainerBuilder AddHttpClient();
    /// <summary>
    /// 注入生命周期共享实例
    /// </summary>
    /// <param name="serviceType">接口类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped(Type serviceType, string? keyName = null);
    /// <summary>
    /// 注入生命周期共享实例
    /// </summary>
    /// <param name="serviceType">接口类</param>
    /// <param name="implementationType">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped(Type serviceType, Type implementationType, string? keyName = null);
    /// <summary>
    /// 为两种接口注入生命周期共享实例
    /// </summary>
    /// <param name="serviceType1">接口类1</param>
    /// <param name="serviceType2">接口类2</param>
    /// <param name="implementationType">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped(Type serviceType1, Type serviceType2, Type implementationType, string? keyName = null);
    /// <summary>
    /// 注入生命周期共享实例
    /// </summary>
    /// <typeparam name="TService"></typeparam>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped<TService>(string? keyName = null) where TService : notnull;
    /// <summary>
    /// 注入生命周期共享实例
    /// </summary>
    /// <typeparam name="TService">服务类</typeparam>
    /// <typeparam name="TImplementation">实现类</typeparam>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped<TService, TImplementation>(string? keyName = null) where TImplementation : notnull, TService where TService : notnull;
    /// <summary>
    /// 为两种接口注入生命周期共享实例
    /// </summary>
    /// <typeparam name="TService1">服务类1</typeparam>
    /// <typeparam name="TService2">服务类2</typeparam>
    /// <typeparam name="TImplementation">实现类</typeparam>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped<TService1, TService2, TImplementation>(string? keyName = null) where TImplementation : notnull, TService1, TService2 where TService1 : notnull where TService2 : notnull;
    /// <summary>
    /// 注入单例
    /// </summary>
    /// <typeparam name="TService">服务类</typeparam>
    /// <typeparam name="TImplementation">实现类</typeparam>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton<TService, TImplementation>(string? keyName = null) where TImplementation : notnull, TService where TService : notnull;
    /// <summary>
    /// 同时注入两种接口的单例
    /// </summary>
    /// <typeparam name="TService1">服务类1</typeparam>
    /// <typeparam name="TService2">服务类2</typeparam>
    /// <typeparam name="TImplementation">实现类</typeparam>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton<TService1, TService2, TImplementation>(string? keyName = null) where TImplementation : notnull, TService1, TService2 where TService1 : notnull where TService2 : notnull;
    /// <summary>
    /// 注入单例
    /// </summary>
    /// <typeparam name="TService">服务类</typeparam>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton<TService>(string? keyName = null) where TService : notnull;
    /// <summary>
    /// 注入单例
    /// </summary>
    /// <param name="serviceType">服务类</param>
    /// <param name="implementationType">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton(Type serviceType, Type implementationType, string? keyName = null);
    /// <summary>
    /// 为两种接口注入单例
    /// </summary>
    /// <param name="serviceType1">服务类1</param>
    /// <param name="serviceType2">服务类2</param>
    /// <param name="implementationType">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton(Type serviceType1, Type serviceType2, Type implementationType, string? keyName = null);
    /// <summary>
    /// 注入服务实例
    /// </summary>
    /// <param name="serviceType">服务类</param>
    /// <param name="implementationInstance">实现类实例</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton(Type serviceType, object implementationInstance, string? keyName = null);
    /// <summary>
    /// 注入单例服务实例
    /// </summary>
    /// <param name="serviceType1">服务类1</param>
    /// <param name="serviceType2">服务类2</param>
    /// <param name="implementationInstance">实现类实例</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton(Type serviceType1, Type serviceType2, object implementationInstance, string? keyName = null);
    /// <summary>
    /// 注入单例服务实例
    /// </summary>
    /// <typeparam name="TService">服务类</typeparam>
    /// <param name="implementationInstance">实现类实例</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton<TService>(TService implementationInstance, string? keyName = null) where TService : notnull;
    /// <summary>
    /// 注入单例服务实例
    /// </summary>
    /// <typeparam name="TService1">服务类</typeparam>
    /// <typeparam name="TService2">服务类</typeparam>
    /// <typeparam name="TImplementation">实现类</typeparam>
    /// <param name="implementationInstance">实现类实例</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton<TService1, TService2, TImplementation>(TImplementation implementationInstance, string? keyName = null) where TImplementation : notnull, TService1, TService2 where TService1 : notnull where TService2 : notnull;
    /// <summary>
    /// 注入单例服务实例
    /// </summary>
    /// <param name="serviceType">服务类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton(Type serviceType, string? keyName = null);
    /// <summary>
    /// 注入每次都获取实例
    /// </summary>
    /// <param name="serviceType">服务类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient(Type serviceType, string? keyName = null);
    /// <summary>
    /// 注入每次都获取实例
    /// </summary>
    /// <param name="serviceType">服务类</param>
    /// <param name="implementationType">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient(Type serviceType, Type implementationType, string? keyName = null);
    /// <summary>
    /// 为两种接口注入每次都获取实例
    /// </summary>
    /// <param name="serviceType1">服务类1</param>
    /// <param name="serviceType2">服务类2</param>
    /// <param name="implementationType">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient(Type serviceType1, Type serviceType2, Type implementationType, string? keyName = null);
    /// <summary>
    /// 注入每次都获取实例
    /// </summary>
    /// <typeparam name="TService">服务类</typeparam>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient<TService>(string? keyName = null) where TService : notnull;
    /// <summary>
    /// 注入每次都获取实例
    /// </summary>
    /// <typeparam name="TService">服务类</typeparam>
    /// <typeparam name="TImplementation">实现类</typeparam>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient<TService, TImplementation>(string? keyName = null) where TImplementation : notnull, TService where TService : notnull;
    /// <summary>
    /// 为两种接口注入每次都获取实例
    /// </summary>
    /// <typeparam name="TService1">服务类1</typeparam>
    /// <typeparam name="TService2">服务类2</typeparam>
    /// <typeparam name="TImplementation">实现类</typeparam>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient<TService1, TService2, TImplementation>(string? keyName = null) where TImplementation : notnull, TService1, TService2 where TService1 : notnull where TService2 : notnull;
    /// <summary>
    /// 注入生命周期共享实例
    /// </summary>
    /// <param name="serviceType">接口类</param>
    /// <param name="implementationFactory">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped(Type serviceType, Func<ILifeTime, object> implementationFactory, string? keyName = null);
    /// <summary>
    /// 注入生命周期共享实例
    /// </summary>
    /// <typeparam name="TService"></typeparam>
    /// <param name="implementationFactory"></param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped<TService>(Func<ILifeTime, object> implementationFactory, string? keyName = null) where TService : notnull;
    /// <summary>
    /// 注入生命周期共享实例
    /// </summary>
    /// <param name="serviceType1">服务类</param>
    /// <param name="serviceType2">服务类</param>
    /// <param name="implementationFactory">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped(Type serviceType1, Type serviceType2, Func<ILifeTime, object> implementationFactory, string? keyName = null);
    /// <summary>
    /// 为两种接口注入生命周期共享实例
    /// </summary>
    /// <typeparam name="TService1">服务类1</typeparam>
    /// <typeparam name="TService2">服务类2</typeparam>
    /// <param name="implementationFactory"></param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped<TService1, TService2>(Func<ILifeTime, object> implementationFactory, string? keyName = null) where TService1 : notnull where TService2 : notnull;
    /// <summary>
    /// 注入单例
    /// </summary>
    /// <typeparam name="TService">服务类</typeparam>
    /// <param name="implementationFactory"></param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton<TService>(Func<ILifeTime, object> implementationFactory, string? keyName = null) where TService : notnull;
    /// <summary>
    /// 为两种接口注入单例
    /// </summary>
    /// <typeparam name="TService1">服务类1</typeparam>
    /// <typeparam name="TService2">服务类2</typeparam>
    /// <param name="implementationFactory"></param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton<TService1, TService2>(Func<ILifeTime, object> implementationFactory, string? keyName = null) where TService1 : notnull where TService2 : notnull;
    /// <summary>
    /// 为两种接口注入单例
    /// </summary>
    /// <param name="serviceType1">服务类1</param>
    /// <param name="serviceType2">服务类2</param>
    /// <param name="implementationFactory">实现类实例</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton(Type serviceType1, Type serviceType2, Func<ILifeTime, object> implementationFactory, string? keyName = null);
    /// <summary>
    /// 注入每次都获取实例
    /// </summary>
    /// <param name="serviceType">服务类</param>
    /// <param name="implementationFactory">实现类工厂</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient(Type serviceType, Func<ILifeTime, object> implementationFactory, string? keyName = null);
    /// <summary>
    /// 为两种接口注入每次都获取实例
    /// </summary>
    /// <param name="serviceType1">服务类1</param>
    /// <param name="serviceType2">服务类2</param>
    /// <param name="implementationFactory">实现类工厂</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient(Type serviceType1, Type serviceType2, Func<ILifeTime, object> implementationFactory, string? keyName = null);
    /// <summary>
    /// 注入每次都获取实例
    /// </summary>
    /// <typeparam name="TService">服务类</typeparam>
    /// <param name="implementationFactory">实现工厂</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient<TService>(Func<ILifeTime, object> implementationFactory, string? keyName = null) where TService : notnull;
    /// <summary>
    /// 为两种接口注入每次都获取实例
    /// </summary>
    /// <typeparam name="TService1">服务类1</typeparam>
    /// <typeparam name="TService2">服务类2</typeparam>
    /// <param name="implementationFactory">实现工厂</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient<TService1, TService2>(Func<ILifeTime, object> implementationFactory, string? keyName = null) where TService1 : notnull where TService2 : notnull;
    /// <summary>
    /// 注入生命周期共享实例
    /// </summary>
    /// <param name="serviceType">接口类</param>
    /// <param name="implementationFactory">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped(Type serviceType, Func<ILifeTime, object?, object> implementationFactory, string? keyName = null);
    /// <summary>
    /// 注入生命周期共享实例
    /// </summary>
    /// <typeparam name="TService"></typeparam>
    /// <param name="implementationFactory"></param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped<TService>(Func<ILifeTime, object?, object> implementationFactory, string? keyName = null) where TService : notnull;
    /// <summary>
    /// 注入生命周期共享实例
    /// </summary>
    /// <param name="serviceType1">服务类</param>
    /// <param name="serviceType2">服务类</param>
    /// <param name="implementationFactory">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped(Type serviceType1, Type serviceType2, Func<ILifeTime, object?, object> implementationFactory, string? keyName = null);
    /// <summary>
    /// 为两种接口注入生命周期共享实例
    /// </summary>
    /// <typeparam name="TService1">服务类1</typeparam>
    /// <typeparam name="TService2">服务类2</typeparam>
    /// <param name="implementationFactory"></param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddScoped<TService1, TService2>(Func<ILifeTime, object?, object> implementationFactory, string? keyName = null) where TService1 : notnull where TService2 : notnull;
    /// <summary>
    /// 注入单例
    /// </summary>
    /// <param name="serviceType">接口类</param>
    /// <param name="implementationFactory">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton(Type serviceType, Func<ILifeTime, object?, object> implementationFactory, string? keyName = null);
    /// <summary>
    /// 注入单例
    /// </summary>
    /// <typeparam name="TService"></typeparam>
    /// <param name="implementationFactory"></param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton<TService>(Func<ILifeTime, object?, object> implementationFactory, string? keyName = null) where TService : notnull;
    /// <summary>
    /// 为两种接口注入单例
    /// </summary>
    /// <param name="serviceType1">服务类</param>
    /// <param name="serviceType2">服务类</param>
    /// <param name="implementationFactory">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton(Type serviceType1, Type serviceType2, Func<ILifeTime, object?, object> implementationFactory, string? keyName = null);
    /// <summary>
    /// 为两种接口注入单例
    /// </summary>
    /// <typeparam name="TService1">服务类1</typeparam>
    /// <typeparam name="TService2">服务类2</typeparam>
    /// <param name="implementationFactory"></param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddSingleton<TService1, TService2>(Func<ILifeTime, object?, object> implementationFactory, string? keyName = null) where TService1 : notnull where TService2 : notnull;
    /// <summary>
    /// 注入每次都获取实例
    /// </summary>
    /// <param name="serviceType">接口类</param>
    /// <param name="implementationFactory">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient(Type serviceType, Func<ILifeTime, object?, object> implementationFactory, string? keyName = null);
    /// <summary>
    /// 注入每次都获取实例
    /// </summary>
    /// <typeparam name="TService"></typeparam>
    /// <param name="implementationFactory"></param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient<TService>(Func<ILifeTime, object?, object> implementationFactory, string? keyName = null) where TService : notnull;
    /// <summary>
    /// 为两种接口注入每次都获取实例
    /// </summary>
    /// <param name="serviceType1">服务类</param>
    /// <param name="serviceType2">服务类</param>
    /// <param name="implementationFactory">实现类</param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient(Type serviceType1, Type serviceType2, Func<ILifeTime, object?, object> implementationFactory, string? keyName = null);
    /// <summary>
    /// 为两种接口注入每次都获取实例
    /// </summary>
    /// <typeparam name="TService1">服务类1</typeparam>
    /// <typeparam name="TService2">服务类2</typeparam>
    /// <param name="implementationFactory"></param>
    /// <param name="keyName">注册命名实例</param>
    /// <returns></returns>
    IContainerBuilder AddTransient<TService1, TService2>(Func<ILifeTime, object?, object> implementationFactory, string? keyName = null) where TService1 : notnull where TService2 : notnull;
    /// <summary>
    /// 注册创建容器后的回调函数
    /// <para>创建容器后自动执行</para>
    /// </summary>
    /// <param name="action"></param>
    void OnIocBuilded(Action<ILifeTime> action);
    /// <summary>
    /// 注册创建容器后的回调函数
    /// <para>创建容器后自动执行</para>
    /// </summary>
    /// <param name="action"></param>
    void OnIocBuilded(Func<ILifeTime, Task> action);
    /// <summary>
    /// 添加控制器程序集(仅用于新增其他插件)
    /// </summary>
    /// <param name="assembly"></param>
    void AddControllerAssembly(Assembly assembly);
}